﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows;

namespace Luminji.Core.Xaml.Common
{
    /// <summary>
    /// 试题流文档(重写 FlowDocument)
    /// </summary>
    public class QuestionFlowDocument : FlowDocument
    {
        /// <summary>
        /// 构造方法(设置流文档的全局属性)
        /// </summary>
        public QuestionFlowDocument()
        {
            //MSDN:http://msdn.microsoft.com/zh-cn/library/system.windows.documents.flowdocument_members.aspx
            this.FontFamily = new FontFamily("微软雅黑");
            this.FontSize = 12.0;
            this.LineHeight = 1.0;
            this.AllowDrop = true;
            this.PagePadding = new Thickness(5, 0, 5, 0);
        }
        /// <summary>
        /// 获取空Xaml字符串(文本空)
        /// </summary>
        public static string DocumentEmptyXaml
        {
            get { return DocumentEmptyXamlHeader + "<av:Paragraph><av:Run xml:lang=\"zh-cn\" xml:space=\"preserve\" /></av:Paragraph>" + DocumentEmptyXamlFoot; }
        }
        /// <summary>
        /// 获取空Xaml字符串(头)
        /// </summary>
        public static string DocumentEmptyXamlHeader
        {
            get { return "<QuestionFlowDocument FontFamily=\"微软雅黑\" FontSize=\"12\" LineHeight=\"1\" PagePadding=\"5,0,5,0\" AllowDrop=\"True\" xmlns=\"clr-namespace:QuestionBank.Controls;assembly=QuestionBank.Controls\" xmlns:av=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">"; }
        }
        /// <summary>
        /// 获取空Xaml字符串(头)[此包含xmlns:x的命名空间]
        /// </summary>
        public static string DocumentEmptyXamlHeaderContainX
        {
            get { return "<QuestionFlowDocument FontFamily=\"微软雅黑\" FontSize=\"12\" LineHeight=\"1\" PagePadding=\"5,0,5,0\" AllowDrop=\"True\" xmlns=\"clr-namespace:QuestionBank.Controls;assembly=QuestionBank.Controls\" xmlns:av=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">"; }
        }
        /// <summary>
        /// 获取空Xaml字符串(尾)
        /// </summary>
        public static string DocumentEmptyXamlFoot
        {
            get { return "</QuestionFlowDocument>"; }
        }
        /// <summary>
        /// 获取空Xaml字符串
        /// </summary>
        public static string DocumentNullXaml
        {
            get { return ExamXamlConverter.FlowDocumentToXaml(new QuestionFlowDocument()); }
        }
        /// <summary>
        /// 重写可用性(使内嵌控件为可用)
        /// </summary>
        protected override bool IsEnabledCore
        {
            get
            {
                return true;
            }
        }
    }    
}
